///*
// * Copyright 2002-2016 the original author or authors.
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// *      http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.ling.pl.core.commons.springmvc;
//
//import com.ling.pl.core.commons.springmvc.constant.FailStatus;
//import com.ling.pl.core.commons.springmvc.constant.ResultField;
//import com.ling.pl.core.commons.springmvc.constant.ResultStatus;
//import org.springframework.core.Conventions;
//import org.springframework.core.MethodParameter;
//import org.springframework.core.annotation.AnnotatedElementUtils;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.http.converter.HttpMessageNotReadableException;
//import org.springframework.http.converter.HttpMessageNotWritableException;
//import org.springframework.http.server.ServletServerHttpRequest;
//import org.springframework.http.server.ServletServerHttpResponse;
//import org.springframework.validation.BindingResult;
//import org.springframework.web.HttpMediaTypeNotAcceptableException;
//import org.springframework.web.HttpMediaTypeNotSupportedException;
//import org.springframework.web.accept.ContentNegotiationManager;
//import org.springframework.web.bind.MethodArgumentNotValidException;
//import org.springframework.web.bind.WebDataBinder;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.support.WebDataBinderFactory;
//import org.springframework.web.context.request.NativeWebRequest;
//import org.springframework.web.method.support.ModelAndViewContainer;
//import org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor;
//import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor;
//import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.lang.reflect.Type;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//public class CloudRequestResponseBodyMethodProcessor extends RequestResponseBodyMethodProcessor {
//
//	/**
//	 * Basic constructor with converters only. Suitable for resolving
//	 * {@code @RequestBody}. For handling {@code @ResponseBody} consider also
//	 * providing a {@code ContentNegotiationManager}.
//	 */
//	public CloudRequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters) {
//		super(converters);
//	}
//
//	/**
//	 * Basic constructor with converters and {@code ContentNegotiationManager}.
//	 * Suitable for resolving {@code @RequestBody} and handling
//	 * {@code @ResponseBody} without {@code Request~} or
//	 * {@code ResponseBodyAdvice}.
//	 */
//	public CloudRequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters,
//											  ContentNegotiationManager manager) {
//
//		super(converters, manager);
//	}
//
//	/**
//	 * Complete constructor for resolving {@code @RequestBody} method arguments.
//	 * For handling {@code @ResponseBody} consider also providing a
//	 * {@code ContentNegotiationManager}.
//	 * @since 4.2
//	 */
//	public CloudRequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters,
//											  List<Object> requestResponseBodyAdvice) {
//
//		super(converters, null, requestResponseBodyAdvice);
//	}
//
//	/**
//	 * Complete constructor for resolving {@code @RequestBody} and handling
//	 * {@code @ResponseBody}.
//	 */
//	public CloudRequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters,
//											  ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice) {
//
//		super(converters, manager, requestResponseBodyAdvice);
//	}
//
//	@Override
//	public void handleReturnValue(Object returnValue, MethodParameter returnType,
//								  ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
//			throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException {
//
//		mavContainer.setRequestHandled(true);
//		ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
//		ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);
//
//		/************************bo.wang*******************/
//		Map<String, Object> temp=new HashMap<String, Object>();
//		if (returnValue != null||(returnValue==null&&"void".equals(returnType.getParameterType().toString()))) {
//			temp.put(ResultField.STATUS, ResultStatus.SUCCESS);
//			temp.put(ResultField.DATA, returnValue);
//		}else{
//			temp.put(ResultField.STATUS, ResultStatus.FAIL);
//			temp.put(ResultField.ERROCODE, FailStatus.NULLDATA);
//			temp.put(ResultField.ERROMESSAGE, "空数据");
//		}
//		/**************************/
//		// Try even with null return value. ResponseBodyAdvice could get involved.
//		writeWithMessageConverters(temp, returnType, inputMessage, outputMessage);
//	}
//}
